package com.fit.pages;

import org.apache.tapestry5.annotations.Property;
import org.apache.tapestry5.annotations.SessionState;
import org.apache.tapestry5.ioc.annotations.Inject;

import com.fit.enums.AccountRole;
import com.fit.interfaces.ServiceI;
import com.fit.interfaces.User;
import com.fit.service.ServicesI;

public class BrowseService {

	@SessionState
	private User user;
	
	private boolean userExists;

	public User getUser() {
		return user;
	}

	Object onActivate(){
		if(!userExists) return Login.class;
		if(user.getRole() == AccountRole.USER) return Index.class;
		return null;
	}
	


	@Inject
	@Property
	private ServicesI carServices;
	
	@Property
	private ServiceI currentService;
	
	public boolean isUserAdmin(){
		if(user.getRole() == AccountRole.ADMINISTRATOR) return true;
		return false;
	}
}
